package com.myfum.wingplayer.components
{
	import com.myfum.wingplayer.commands.CheckTaskCommand;
	import com.myfum.wingplayer.commands.ScheduleChangedCommand;
	import com.myfum.wingplayer.commands.StartUpCommand;
	import com.myfum.wingplayer.components.ui.Program;
	import com.myfum.wingplayer.components.ui.ProjectMediator;
	import com.myfum.wingplayer.components.ui.Region;
	import com.myfum.wingplayer.components.ui.RegionMediator;
	import com.myfum.wingplayer.events.TaskEvent;
	import com.myfum.wingplayer.model.ProgramLocator;
	import com.myfum.wingplayer.utils.FileManager;
	import com.myfum.wingplayer.utils.TaskManager;
	
	import flash.display.DisplayObjectContainer;
	
	import mx.core.WindowedApplication;
	
	import org.robotlegs.base.ContextEvent;
	import org.robotlegs.mvcs.Context;
	
	public class MFContext extends Context
	{
		public function MFContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true)
		{
			super(contextView, autoStartup);
		}
		
		override public function startup():void{
			WingPlayer(contextView).addElement(new Program());
			
			injector.mapSingleton(TaskManager);
			injector.mapSingleton(ProgramLocator);
			injector.mapSingleton(FileManager);
			
			mediatorMap.mapView(Program, ProjectMediator);
			mediatorMap.mapView(Region,  RegionMediator);
			
			commandMap.mapEvent(TaskEvent.CHECK_TASK,       CheckTaskCommand, TaskEvent);
			commandMap.mapEvent(TaskEvent.SCHEDULE_CHANGED, ScheduleChangedCommand, TaskEvent);
			commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, StartUpCommand);
			
			super.startup();
		}
	}
}